package com.feng.usercenter.common;

import java.io.Serial;
import java.io.Serializable;

/**
 * 通用返回类
 * @param <T>
 */
public class BaseResult<T> implements Serializable {
    @Serial
    private static final long serialVersionUID = -5527136093302764860L;

    private int code;
    private String message;
    private T data;
    private String description;

    public BaseResult(int code, T data, String message, String description ) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.description = description;
    }

    public BaseResult(int code, T data, String message) {
        this(code, data, message, "");
    }

    public BaseResult(int code, T data) {
        this(code, data, "", "");
    }

    public BaseResult(ErrorCode errorCode) {
        this(errorCode.getCode(), null, errorCode.getMessage(), errorCode.getDescription());
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
